请帮我改一下ASP代码 <%=(help2.Fields.Item("news_title").Value)%>

来源:百度知道 编辑:UC知道 时间:2024/06/23 12:35:46
我在做标题的时候,想要超过20个字后用...加上,我套用下面这个公式却不行,请大侠帮帮我!
变量是这个字段
<%=(help2.Fields.Item("news_title").Value)%>
我用的是Dreamweaver
————————————
这是我套用的
<%
If Len(Rs("Topic.Title"))>100 Then
Response.Write(Left(Rs("Topic.Title")),20)&"..."
Else
Response.Write(Rs("Topic.Title"))
End If
%>
————————————

请大侠帮我套用一下,我套用后总是出错,谢谢了!

Response.Write(Left(Rs("Topic.Title")),20)&"..."
这句括号弄错了
改成
Response.Write(Left(Rs("Topic.Title"),20)&"...")

<%
dim title
if(Len(help2.Fields.Item("news_title").Value)>100) then
title=Left(help2.Fields.Item("news_title").Value,20)&"..."
else
title=help2.Fields.Item("news_title").Value
end if
%>
<%=title %>

不过len函数识别中文不好

这样判断容易出错,注意,英文和汉字得区别